<template>
  <div class="container">
    <!-- 头部导航 - 不在登录页面显示 -->
    <HeaderNav v-if="!isLoginPage" />
    
    <!-- 路由内容 -->
    <router-view v-slot="{ Component }">
      <component 
        :is="Component" 
        @startInspection="openInspectionModal"
        @customRule="openCustomRuleModal"
      />
    </router-view>
    
    <!-- 全局模态框 -->
    <InspectionModal 
      v-model:show="showInspectionModal"
    />
    
    <CustomRuleModal 
      v-model:show="showCustomRuleModal"
      @show-excel="showExcelPage"
    />
    
    <ExcelPage 
      v-model:show="showExcel"
    />
  </div>
</template>

<script setup lang="ts">
import { ref, computed } from 'vue'
import { useRouter } from 'vue-router'

const router = useRouter()
const isLoginPage = computed(() => router.currentRoute.value.path === '/')
import HeaderNav from './components/HeaderNav.vue'
import InspectionModal from './components/InspectionModal.vue'
import CustomRuleModal from './components/CustomRuleModal.vue'
import ExcelPage from './components/ExcelPage.vue'

// 全局模态框状态
const showInspectionModal = ref(false)
const showCustomRuleModal = ref(false)
const showExcel = ref(false)

// 全局方法
const openInspectionModal = () => {
  showInspectionModal.value = true
}

const openCustomRuleModal = () => {
  showCustomRuleModal.value = true
}

const showExcelPage = () => {
  showCustomRuleModal.value = false
  showExcel.value = true
}

// 提供全局方法给子组件使用
defineExpose({
  openInspectionModal,
  openCustomRuleModal
})
</script>